package com.nameless.controller.api;

import com.nameless.entity.CarType;
import com.nameless.entity.CarTypeConfigDetails;
import com.nameless.service.CarTypeConfigDetailsService;
import com.nameless.vo.CarTypeConfigVo;
import com.nameless.vo.Result;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ：潘淼淼
 * @date ：Created in 2023/2/27 9:49
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@Api
@Slf4j
@RequestMapping("/cars/typeConfig")
public class CarTypeConfigDetailsController {
    @Resource
    private CarTypeConfigDetailsService carTypeConfigDetailsService;

    @GetMapping("/getTypeConfigAll")
    public List<CarTypeConfigDetails> getTypeConfigAll(){
        return carTypeConfigDetailsService.getTypeConfigAll();
    }
//   添加
    @PostMapping("/types")
    public Result typeConfigAll(@RequestBody CarTypeConfigVo carTypeConfigVo){
        return carTypeConfigDetailsService.queryTypeConfig(carTypeConfigVo);
    }
    @GetMapping("/typeAll")
    public Result typeConfig(){
        return carTypeConfigDetailsService.queryType();
    }
    //    修改
    @PostMapping("/update")
    public Result update(@RequestBody CarTypeConfigDetails carTypeConfigDetails){
        return carTypeConfigDetailsService.updateAll(carTypeConfigDetails);
    }
    //    删除
    @PostMapping("/del")
    public Result del(Integer id){
        return carTypeConfigDetailsService.deleteById(id);
    }
    @PostMapping("/save")
    public Result save(@RequestBody CarTypeConfigDetails carTypeConfigDetails) {
        return carTypeConfigDetailsService.addOne(carTypeConfigDetails);

    }
}